//
//  ViewController.swift
//  PinInputField
//
//  Created by hongyan.yang on 2022/7/22.
//

import UIKit

class ViewController: UIViewController {
  

    @IBOutlet weak var updatePinView: UpdatePinView!
    override func viewDidLoad() {
        super.viewDidLoad()
        updatePinView.delegate = self
    }

    func showPopupAlert(title: String? = "", message: String?, actionTitles:[String?] = ["Okay"], actions:[((UIAlertAction) -> Void)?] = [nil]) {
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        for (index, title) in actionTitles.enumerated() {
            let action = UIAlertAction(title: title, style: .default, handler: actions[index])
            alert.addAction(action)
        }
        DispatchQueue.main.async {
            self.present(alert, animated: true, completion: nil)
        }
    }
}

extension ViewController: UpdatePinViewDelegate {
    func didChangeState(_ updatePinView: UpdatePinView) {
        print(updatePinView.state)
    }
}
